package br.com.fafica.sisape.view;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.Color;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JButton;

import br.com.fafica.sisape.control.ControllerUsuario;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class TelaUsuarioCadastro extends JFrame {

	private JPanel contentPane;
	private JTextField campoNome;
	private JTextField campoCpf;
	private JTextField campoRua;
	private JTextField campoCidade;
	private JTextField campoTelefone;
	private JTextField campoUsuario;
	private JTextField campoSenha;
	private JTextField campoSexo;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					TelaUsuarioCadastro frame = new TelaUsuarioCadastro();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public TelaUsuarioCadastro() {
		setResizable(false);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 270, 410);
		contentPane = new JPanel();
		contentPane.setBackground(Color.WHITE);
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JLabel lblNome = new JLabel("Nome:");
		lblNome.setForeground(Color.BLUE);
		lblNome.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblNome.setBounds(10, 11, 46, 14);
		contentPane.add(lblNome);
		
		campoNome = new JTextField();
		campoNome.setForeground(Color.BLUE);
		campoNome.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoNome.setBounds(10, 28, 234, 26);
		contentPane.add(campoNome);
		campoNome.setColumns(10);
		
		JLabel lblCpf = new JLabel("Cpf:");
		lblCpf.setForeground(Color.BLUE);
		lblCpf.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblCpf.setBounds(10, 59, 46, 14);
		contentPane.add(lblCpf);
		
		campoCpf = new JTextField();
		campoCpf.setForeground(Color.BLUE);
		campoCpf.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoCpf.setColumns(10);
		campoCpf.setBounds(10, 76, 234, 26);
		contentPane.add(campoCpf);
		
		JLabel lblEndereo = new JLabel("Endere\u00E7o:");
		lblEndereo.setForeground(Color.BLUE);
		lblEndereo.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblEndereo.setBounds(10, 113, 68, 14);
		contentPane.add(lblEndereo);
		
		campoRua = new JTextField();
		campoRua.setForeground(Color.BLUE);
		campoRua.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoRua.setColumns(10);
		campoRua.setBounds(10, 130, 234, 26);
		contentPane.add(campoRua);
		
		JLabel lblCidade = new JLabel("Cidade:");
		lblCidade.setForeground(Color.BLUE);
		lblCidade.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblCidade.setBounds(10, 167, 46, 14);
		contentPane.add(lblCidade);
		
		campoCidade = new JTextField();
		campoCidade.setForeground(Color.BLUE);
		campoCidade.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoCidade.setColumns(10);
		campoCidade.setBounds(10, 184, 234, 26);
		contentPane.add(campoCidade);
		
		JLabel lblTelefone = new JLabel("Telefone:");
		lblTelefone.setForeground(Color.BLUE);
		lblTelefone.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblTelefone.setBounds(10, 221, 68, 14);
		contentPane.add(lblTelefone);
		
		campoTelefone = new JTextField();
		campoTelefone.setForeground(Color.BLUE);
		campoTelefone.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoTelefone.setColumns(10);
		campoTelefone.setBounds(10, 238, 106, 26);
		contentPane.add(campoTelefone);
		
		JLabel lblUsurio = new JLabel("Usu\u00E1rio:");
		lblUsurio.setForeground(Color.BLUE);
		lblUsurio.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblUsurio.setBounds(10, 272, 46, 14);
		contentPane.add(lblUsurio);
		
		campoUsuario = new JTextField();
		campoUsuario.setForeground(Color.BLUE);
		campoUsuario.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoUsuario.setColumns(10);
		campoUsuario.setBounds(10, 289, 134, 26);
		contentPane.add(campoUsuario);
		
		JLabel lblSenha = new JLabel("Senha:");
		lblSenha.setForeground(Color.BLUE);
		lblSenha.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblSenha.setBounds(10, 317, 46, 14);
		contentPane.add(lblSenha);
		
		campoSenha = new JTextField();
		campoSenha.setForeground(Color.BLUE);
		campoSenha.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoSenha.setColumns(10);
		campoSenha.setBounds(10, 334, 134, 26);
		contentPane.add(campoSenha);
		
		JButton btnSalvar = new JButton("Salvar");
		btnSalvar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String nome = campoNome.getText();
				String cpf = campoCpf.getText();
				String rua = campoRua.getText();
				String cidade = campoCidade.getText();
				String telefone = campoTelefone.getText();
				String sexo = campoSexo.getText();
				String usuario = campoUsuario.getText();
				String senha = campoSenha.getText();
				
				ControllerUsuario control = new  ControllerUsuario();
				control.InserirUsuario(nome, cpf, rua, cidade, telefone, sexo, usuario, senha);
				dispose();
			}
		});
		btnSalvar.setForeground(Color.BLUE);
		btnSalvar.setFont(new Font("Tahoma", Font.PLAIN, 12));
		btnSalvar.setBounds(154, 333, 89, 27);
		contentPane.add(btnSalvar);
		
		JLabel lblSexo = new JLabel("Sexo:");
		lblSexo.setForeground(Color.BLUE);
		lblSexo.setFont(new Font("Tahoma", Font.PLAIN, 12));
		lblSexo.setBounds(126, 221, 68, 14);
		contentPane.add(lblSexo);
		
		campoSexo = new JTextField();
		campoSexo.setForeground(Color.BLUE);
		campoSexo.setFont(new Font("Tahoma", Font.PLAIN, 12));
		campoSexo.setColumns(10);
		campoSexo.setBounds(126, 238, 106, 26);
		contentPane.add(campoSexo);
	}
}
